﻿{extend name="public:public" /}
{block name="section"}
<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页<span class="c-gray en">&gt;</span> 会员列表<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="Hui-article">

		<article class="cl pd-20">
			<form action="" method="get">
			<div class="text-c"> 日期范围：
				<input type="text" name="start_time" onfocus="WdatePicker({maxDate:'#F{ $dp.$D(\'datemax\')||\'%y-%M-%d\'}'})" id="datemin" class="input-text Wdate" style="width:120px;">
				-
				<input type="text" name="end_time" onfocus="WdatePicker({minDate:'#F{ $dp.$D(\'datemin\')}',maxDate:'%y-%M-%d'})" id="datemax" class="input-text Wdate" style="width:120px;">
				<input type="text" class="input-text" style="width:130px" placeholder="会员名称"  name="nickname">
				<input type="text" class="input-text" style="width:130px" placeholder="手机号" name="tel">
				<button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
			</div>
			</form>
			<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> </span> <span class="r">共有数据：<strong>{:count($lists)}</strong> 条</span> </div>
			<div class="mt-20">
				<table class="table table-border table-bordered table-hover table-bg table-sort">
					<thead>
						<tr class="text-c">
							<th width="25"><input type="checkbox" name="" value=""></th>
							<th width="20">ID</th>
							<th width="60">昵称</th>
							<th width="50">头像</th>
							<th width="40">性别</th>
							<th width="90">手机</th>
							<th width="30">地址</th>
							<th width="130">加入时间</th>
							<th width="60">积分</th>
							<th width="100">操作</th>
						</tr>
					</thead>
					<tbody>
					{volist name="lists" id="v"}
						<tr class="text-c">
							<td><input type="checkbox" value="{$v->id}" name="user_id"></td>
							<td>{$v->id}</td>
							<td>{$v->nickname}</td>
							<td><a target="_blank" href="{$v->avatar_url ?: '#'}"><img style="width: 40px;height: 40px;" src="{$v->avatar_url ?: ''}" alt=""></a></td>
							<td>{$v->gender ?: ''}</td>
							<td>{$v->tel ?: '无'}</td>
							<td class="text-l">{$v->province ?: ''}</td>
							<td>{$v->create_time}</td>
							<td>{$v->points}</td>
							<td class="td-manage"> <a title="编辑" href="javascript:;" onclick="member_edit('编辑','/admin/user/edi','{$v->id}','800','510')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>  <a title="删除" href="javascript:;" onclick="member_del(this,'{$v->id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
						</tr>
					{/volist}
					</tbody>
				</table>
				{$lists->render()}
			</div>
		</article>
	</div>
</section>
<script type="text/javascript">
$(function(){
    $('#menu-user').children('dt').addClass('selected');
    $('#menu-user').children('dd').show();
    $('#menu-user').children('dd').find('a').eq(0).css({
        color:'#148cf1',
        backgroundColor:'#FFF'
    });
	// $('.table-sort').dataTable({
	// 	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	// 	"bStateSave": true,//状态保存
	// 	"aoColumnDefs": [
	// 	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	// 	  {"orderable":false,"aTargets":[0,8,9]}// 制定列不参与排序
	// 	]
	// });
	$('.table-sort tbody').on( 'click', 'tr', function () {
		if ( $(this).hasClass('selected') ) {
			$(this).removeClass('selected');
		}
		else {
			table.$('tr.selected').removeClass('selected');
			$(this).addClass('selected');
		}
	});
});
//批量删除方法
function datadel(){
    var checkbox = $(":checked");
    var id = [];
    for (var i=0;i<checkbox.length;i++)
    {
        //如果用户选择批量删除
        if(!checkbox.eq(i).val()){
            continue;
        }
        id.push(checkbox.eq(i).val());
    }
    $.ajax({
		type:'post',
		data:{ id:id },
		url:'/admin/user/delall',
		success:function(data){
            layer.msg(data.msg,{icon:1,time:2000},function() {
                var index = parent.layer.getFrameIndex(window.name);
                window.parent.location.reload();
                parent.layer.close(index);
            })
		}
	});
}

/*用户-编辑*/
function member_edit(title,url,id,w,h){
	layer_show(title,url+'/id/'+id,w,h);
}

/*用户-删除*/
function member_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
        $.get("/admin/user/del", {id:id},function(data){
            if(data == 1){
                $(obj).parents("tr").remove();
                layer.msg('已删除!',{icon:1,time:1000});
			}else{
                layer_msg('删除数据失败',{icon:1,time:1000});
			}
        });

	});
}
</script>
{/block}

